import './setAdd.less';
import { Link } from 'umi';
import { Space } from 'antd';
import { ArrowLeftOutlined } from '@ant-design/icons';
import { Button, DatePicker, Form, Select, Input,message } from 'antd';

const formItemLayout = {
    labelCol: {
        xs: { span: 40 },
        sm: { span: 10 },
    },
    wrapperCol: {
        xs: { span: 40 },
        sm: { span: 30 },
    },
};//表格
const { Option } = Select;

const config = {
    rules: [{ type: 'object' as const, required: true, message: 'Please select time!' }],
};//时间日期
type FieldType = {
    companyName?: string;
    infoCode?: string;
    industry?: string;
    accountStandard?:string;
    openTime?:string;
  };
function SetEdit() {
    const [form] = Form.useForm();

    const onFinish = (values: any) => {
        console.log('Received values of form: ', values);
    };
    // 保存成功的消息提示
    const [messageApi, contextHolder] = message.useMessage();
    const onAdd = () => {
        
        messageApi.open({
          type: 'success',
          content: '保存成功',
        });
        console.log(111);
        
      };
    return <div>
        {contextHolder}
        <Link style={{
            color: 'black',
            display: 'flex',
            justifyContent: 'flex-end',
            padding: '20px',
            height: '20px'
        }} to={'/home/settings/set/setCompany'}>
            <Space className='addSpace'>
                <ArrowLeftOutlined />返回
            </Space>
        </Link>
        <div className="addForm">
            <Form
                {...formItemLayout}
                form={form}
                name="register"
                onFinish={onFinish}
                initialValues={{ residence: ['zhejiang', 'hangzhou', 'xihu'], prefix: '86' }}
            >
                <Form.Item<FieldType>
                    name="companyName"
                    label="公司名称："
                    rules={[{ required: true, message: 'Please input your nickname!', whitespace: true },
                    {pattern:/^[\\u4E00-\\u9FA5A-Za-z0-9]{2,20}$/,message:'公司名称必须是2-20个字符'}]}
                >
                    <Input placeholder='请完整填写公司名称' />
                </Form.Item>
                <Form.Item<FieldType>
                    name="infoCode"
                    label="统一社会信用代码："
                >
                    <Input />
                </Form.Item>
                <Form.Item<FieldType>
                    name="industry"
                    label="所属行业："
                >
                    <Select>
                        <Option value="internet">互联网</Option>
                        <Option value="commerce">电商</Option>
                        <Option value="finance">金融</Option>
                        <Option value="husbandry">畜牧业</Option>
                        <Option value="service">服务行业</Option>
                        <Option value="imports ">进出口</Option>
                        <Option value="other">其它</Option>
                    </Select>
                </Form.Item>
                <Form.Item<FieldType> name="openTime" label="启用年份" {...config}>
                    <DatePicker />
                </Form.Item>
                <Form.Item<FieldType>
                    name="accountStandard"
                    label="会计准则"
                    rules={[{ required: true, message: 'Please select gender!' }]}
                >
                    <Select placeholder="小会计准则">
                        <Option value="new">新会计准则</Option>
                        <Option value="peanuts">小企业会计准则</Option>
                        <Option value="special">特殊业务会计准则</Option>
                    </Select>
                </Form.Item>
                <Form.Item className='addFormBtn'>
                    <Button>
                        取消
                    </Button>
                    <Button htmlType="submit" >
                        保存
                    </Button>
                </Form.Item>
            </Form>

        </div>
        {/* <div className='editFormBtn'>
            <button>取消</button>
            <button>保存</button>
        </div> */}
    </div>
};
export default SetEdit;